home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / printq.exe / MAIN.CPP < prev    next >
C/C++ Source or Header  |  1993-05-23  |  2KB  |  75 lines

  1. #define Uses_TApplication
  2. #define Uses_TMenuBar
  3. #define Uses_TSubMenu
  4. #define Uses_TMenuItem
  5. #define Uses_TKeys
  6. #define Uses_TEvent
  7. #define Uses_TFileDialog
  8. #define Uses_TDeskTop
  9. #define Uses_MsgBox
  10. #include <tv.h>
  11.  
  12. #include "PrintApp.h"
  13.  
  14. const
  15.     cmPrintFile = 100;
  16.  
  17. class TApp : public TPrintApp
  18.     {
  19.     public:
  20.  
  21.         TApp();
  22.  
  23.         virtual void handleEvent(TEvent&);
  24.  
  25.         static TMenuBar* initMenuBar(TRect);
  26.     };
  27.  
  28. TApp::TApp() : TProgInit(initStatusLine, initMenuBar, initDeskTop),
  29.                TPrintAppInit(initPrintQueue)
  30.     {}
  31.  
  32. void TApp::handleEvent(TEvent& event)
  33.     {
  34.     TPrintApp::handleEvent(event);
  35.  
  36.     if(event.what == evCommand && event.message.command == cmPrintFile)
  37.         {
  38.         TFileDialog* dlg = new TFileDialog("*.*", "Print A File", "~N~ame",
  39.             fdOKButton, 101);
  40.         if(validView(dlg) != 0)
  41.             {
  42.             if(deskTop->execView(dlg) == cmFileOpen)
  43.                 {
  44.                 char fspec[170];
  45.                 dlg->getFileName(fspec);
  46.                 if(!message(this, evCommand, cmAddPrintJob, new PrintFile(fspec, 128)))
  47.                     messageBox("Can't print that file", mfError|mfOKButton);
  48.                 }
  49.             destroy(dlg);
  50.             }
  51.         clearEvent(event);
  52.         }
  53.     }
  54.  
  55. TMenuBar* TApp::initMenuBar(TRect r)
  56.     {
  57.     r.b.y = r.a.y+1;
  58.     return new TMenuBar(r,
  59.         *new TSubMenu("~F~ile", 0)+
  60.             *new TMenuItem("~P~rint a file...", cmPrintFile, kbNoKey, hcNoContext, 0)+
  61.             newLine()+
  62.             *new TMenuItem("E~x~it", cmQuit, kbAltX, hcNoContext, "Alt-X")
  63.         );
  64.     }
  65.  
  66. int main()
  67.     {
  68.     TApp app;
  69.  
  70.     if(app.valid(cmValid))
  71.         app.run();
  72.     app.shutDown();
  73.     return 0;
  74.     }
  75.